//
//  UILabel+Extension.swift
//  glzbowei
//
//  Created by 高伦展 on 2017/11/26.
//  Copyright © 2017年 glz. All rights reserved.
//

import UIKit

extension UILabel {
    
    //fontSize 默认14，
    //color 默认darkGray，
    //screenInset 相对与屏幕左右的缩进，默认为0，居中显示，如果设置，则左对齐
    convenience init(title:String,
                     fontSize:CGFloat = 14,
                     color:UIColor = UIColor.darkGray,
                     screenInset:CGFloat = 0){
       self.init()
        
       text = title
       textColor = color
       font = UIFont.systemFont(ofSize: fontSize)
        
       numberOfLines = 0
        if screenInset == 0 {
            textAlignment = .center
        }else{
            //设置换行宽度
            preferredMaxLayoutWidth = UIScreen.main.bounds.width - 2 * screenInset
            textAlignment = .left
        } 
    }
}
